package edu.bbte;

public class Test {
	public static void main(String [] args) {
	/*	MatrixCube a;
		a = new MatrixCube(2);
		a.setBound(9);
		try {
			a.readCubeFromFile("files/be.txt");
		} catch (MatrixException e) {
			e.printStackTrace();
		}
		a.printAll();
		a.printCubeToFile("files/ki.txt");
		if (a.shiftCubeBack()) {System.out.println("OK");}
		
		a.printAll();
					
			a.shiftCubeForward();
			a.printAll();
			a.shiftCubeForward();
			a.printAll();
			a.shiftCubeForward();
			a.printAll();
			a.shiftCubeRight();
			a.printAll();
			a.printAll();
			a.rotateCubeX();
			a.printAll();
			MatrixCube [] c = a.listOfCubeRotations();
			boolean jo = true;
			for (int i = 0; i<23; ++i)
				for (int j=i+1; j<24; ++j)
					if (c[i].equalsCube(c[j]))
						jo = false;
			if (!jo)
				System.out.println("Nem jo a forgatas!");
			else
				System.out.println("Joo te a forgatas (elvileg)!");
		//teszteles
		MatrixCube [] l = new MatrixCube[7];
		int i;
		for (i=0; i<7; i++) {
			l[i] = new MatrixCube(3);
			try {
				l[i].readCubeFromFile("files/1/1."+(i+1)+".txt");
			} catch (MatrixException e) {
				e.printStackTrace();
			}
		}
		
		
		MatrixCube o;
			l[0].sumCube(l[1]);
			o = l[0];
			for (i=2; i<7; i++)
				l[i].sumCube(l[i-1]);
			l[1].printCube();
		*/
		
		/*
		MatrixCube c1, c2, c3;
		c1 = new MatrixCube(3);
		c2 = new MatrixCube(3);
		c3 = new MatrixCube(3);
		try {
			c1.readCubeFromFile("files/examples/2/2.1.txt");
			c2.readCubeFromFile("files/examples/2/2.2.txt");
		} catch (MatrixException e) {
			e.printStackTrace();
		}
		c1.printAll();
		c3 = c2.rotateCubeZ();
		c3 = c3.rotateCubeX();
		c3.printAll();
		if (c1.sumCube(c3))
			System.out.println("Essze lehet adni");
		else
			System.out.println("Nem lehet esszeadni");
		if (c3.equalsCube(c2))
			System.out.println("Hat egyenloo");
		c1.printAll();
		*/
		/*
		MatrixCube [] shifts = c1.listOfCubeShifts(3,3,3,3,3,3);//c.listOfCubeShifts(2, 2, 2, 2, 2, 2);
		System.out.println("Az osszes eltolas: ");
		int n = shifts.length;
		boolean jo = true;
		int i;
		for (i = 0; i<(n-1); ++i)
			for (int j=i+1; j<n; ++j)
				if (shifts[i].equalsCube(shifts[j])) {
					jo = false;
					shifts[i].printAll();
					shifts[j].printAll();
					System.out.println(i+" "+j+" alma a fa alatt aaaaaaaaaaaaaaaaaaa");
				}
		if (!jo)
			System.out.println("Nem jo a forgatas!");
		else
			System.out.println("Joo te a forgatas (elvileg)!" + n);
		//for (i = 0; i<n; ++i)
			//shifts[i].printAll();
		//shifts[1].printAll();
		 */
		MatrixCube c;
		c = new MatrixCube(3);
		c.setBound(9);
		try {
			c.readCubeFromFile("2/2.1.txt");
		} catch (MatrixException e) {
			e.printStackTrace();
		}
		MatrixCube [] shifts = c.listOfCubeRotations();//c.listOfCubeShifts(2, 2, 2, 2, 2, 2);
	//	System.out.println("Az osszes eltolas: ");
		int n = shifts.length;
		for (int i=0; i<n; ++i) {
			//shifts[i].printAll();
			//System.out.println("Az "+i+". forgatas:");
		}
			
		int number = 7;
		Matrix3D [] p = new Matrix3D[number];
		for (int i=1; i<=number; ++i) {
			p[i-1] = new Matrix3D(3);
			try {
				String s = "1/" + i + ".txt";
				p[i-1].readCubeFromFile(s);
			} catch (MatrixException e) {
				e.printStackTrace();
			}
		}
		
		SolveCube solv = new SolveCube(p, number);
		long stime=System.currentTimeMillis();
		Matrix3D solution[] = new Matrix3D[6];
		solution = solv.getSolutions3D();
		
		long time=System.currentTimeMillis()-stime;
		System.out.println("Build time:"+(time/1000F)+" sec");
		MatrixCube fin = new MatrixCube(3);
		for (int i=0; i < number; ++i) {
			System.out.println("Az "+i+". matrix:");
			solution[i].printMatrix();
			MatrixCube temp = new MatrixCube(3);
			temp.setCube(solution[i]);
			if(!fin.sumCube(temp))
				System.out.println("Gaz van!");
		}
		System.out.println("Fin");
		fin.printCube();
	}
	
	
	
}
